package com.cloud.controller;

import com.cloud.config.Log;
import com.cloud.domain.LoginUser;
import com.cloud.pojo.ApprovalNoticeForApproval;
import com.cloud.service.ApprovalNoticeService;
import com.cloud.tools.CommonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： linJianHong
 * @dateTime： 23:28 2022/4/23
 * @Description:
 * @ClassName:
 */

@RequestMapping("/approval/notice")
@RestController
public class ApprovalNoticeController {
    @Resource
    ApprovalNoticeService approvalNoticeService;

    /* 审批员创建公告 */
    @PostMapping(value = "/create")
    @PreAuthorize("hasAnyAuthority('notice:create')")
    @Log("审批员创建公告")
    public CommonResult create(@RequestBody Map<String,Object> map){
        return approvalNoticeService.create(map);
    }

    /* 审批员修改公告 */
    @PostMapping(value = "/update")
    @PreAuthorize("hasAnyAuthority('notice:update')")
    @Log("审批员修改公告")
    public CommonResult update(@RequestBody Map<String,Object> map){
        return approvalNoticeService.update(map);
    }

    /* 审批员删除公告 */
    @PostMapping(value = "/delete")
    @PreAuthorize("hasAnyAuthority('notice:delete')")
    @Log("审批员删除公告")
    public CommonResult delete(@RequestBody Map<String,Object> map){
        return approvalNoticeService.delete(map);
    }

    /* 审批员查看自己发布的公告 */
    @GetMapping(value = "/retrieve")
    @PreAuthorize("hasAnyAuthority('notice:read')")
    public CommonResult retrieve(){

        return approvalNoticeService.retrieve();
    }
}
